<?php

class MallController extends Controller
{

    /*
    * 获取一级分类列表
    *
    */
    public function actionGetMaterialTypeList()
    {
        try {
            //参数验证

            //检测
            //$user_id = SessionService::getUserIDBySessionid();


            //获取列表
            $searchsql = Util::initSearchSql();

            //排序
            $searchsql = $searchsql . " order by sort asc,create_time  desc";
            //获取list
            $list = MallMaterialType::model()->findAll($searchsql);


                //返回数据
                Util::responseList(count($list), $list);


            } catch (Exception $e) {
            Util::responseErrorMsg($e->getMessage());

        }
    }

    /*
    * 获取二级分类列表
    *
    */
    public function actionGetMaterialList()
    {
        try {
            //参数验证

            //检测
            //$user_id = SessionService::getUserIDBySessionid();

            //参数验证
            $type_id = Util::getParamNotEmpty("type_id");


            //获取列表
            $searchsql = Util::initSearchSql();

            $searchsql = Util::getSerarchStr($searchsql, "type_id", "type_id");

            //排序
            $searchsql = $searchsql . " order by sort asc,create_time  desc";
            //获取list
            $list = MallMaterial::model()->findAll($searchsql);


                //返回数据
                Util::responseList(count($list), $list);


            } catch (Exception $e) {
            Util::responseErrorMsg($e->getMessage());

        }
    }



}